<!DOCTYPE html>
<html>
<head>

<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">

<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap-responsive.min.css">

<style type="text/css">
.nav { }
.nav li { float: left; width: 110px; }
.container { background-color: #ffffff; padding: 30px; }
.content { padding: 30px; }
body, h1, h2, h3, h4 { font-family: "Trebuchet MS","Helvetica Neue",Arial,Helvetica,sans-serif,"Georgia";}
body { background-color: #eeeeee; }
header { width: 100%; }
blockquote p { font-size: 14px; }
</style>
<title>ZPar | Using ZPar Off-the-Shelf</title>
</head>

<body>
<div class="table-bordered container">
<div class="content">

<header>
<div class="page-header text-center">
<h1>Using ZPar Off-the-Shelf</h1>
</div>
</header>

<h2><a id="Overview">Overview</a></h2>

<p>
ZPar for Chinese (Penn Chinese Treebank), English (Penn Treebank) and ZPar generic (language-independent)
are compiled separately into three independent programs:
<code>zpar.zh</code>, <code>zpar.en</code> and <code>zpar</code>, respectively <a href="#note-1">[1]</a>.
Each program needs to be executed
with a set of corresponding statistical models.
Some example sets of models are released together with ZPar source so that the public release can be used off-the-shelf.
</p>

<p>
The current version of ZPar is 0.7.
Its release contains a set of models for <code>zpar.en</code>,
and a set of models for <code>zpar.zh</code>,
which support labeled dependency parsing and context-free-grammar parsing.
</p>

<h2><a id="Download-and-installation">Download and installation</a></h2>

<p>The source code and models can be downloaded from <a
href=http://www.sourceforge.net/projects/zpar>sourceforge</a>. Unzip the source zip file into the source directory and the corresponding model files each into a model directory.
</p>

To download the models:
<ul>
<li>
Click "Files" on the sourceforge project page.
<br/>
<img src="enter.png" alt="Click Files on the sourceforge project page"> 
<br/>
<br/>
</li>
<li>
Then select the proper version.
<br/>
<img src="version.png" alt="Select the proper version"> 
<br/>
<br/>
</li>
<li>
And download model file for English or Chinese.
<br/>
<img src="model.png" alt="Download model file for English or Chinese"> 
<br/>
<br/>
</li>
</ul>

<p>
To compile ZPar,
type <code>make</code> in the zpar source directory. The binary file <code>zpar</code> will placed
in the <code>dist</code> folder. Type <code>make zpar</code>, <code>make zpar.en</code> and
<code>make zpar.zh</code> to make ZPar for ZPar generic, English and Chinese, respectively. </p>

<h2><a id="Usage-of-ZPar-for-generic">Usage of the generic ZPar</a></h2>
<p>
ZPar is a statistical language analyzer,
which works by using a statistical model.
As a result,
a ZPar binary executable file
must run with a model file.
</p>

<p>Suppose that the source files are saved in the folder <code>zpar</code> and the models are saved in <code>models</code>. To run zpar, type <code>zpar/dist/zpar models</code>, and wait for the models to be loaded. After all models are loaded, type in sentences, and the parses will be printed out on the screen. Alternatively, type <code>zpar/dist/zpar models.en input output</code> to read sentences from the <code>input</code> and write the corresponding parses to <code>output</code>.</p>

<p>Run <code>zpar</code> without command-line arguments to show options. In particular, the <code>-o</code> option controls the type of output. Use <code>-ot</code> to produce POS-tagged sentences,
and
<code>-od</code> to produce dependency structures.
The default option is
<code>-oc</code> which produces constituent structures (brackets).
</p>

<p>
In the following example, inputs were shown in <span style="color:red">red</span> and outputs were shown in <span style="color:blue">blue</span>.
</p>
<pre>
<code>
bash$ <span style="color:red">zpar/dist/zpar -oc models</span>
<span style="color:blue">Parsing started</span>
<span style="color:blue">[tagger] Loading scores ... done.</span>
<span style="color:blue">[parser] Loading scores... done.</span>
<span style="color:red">ZPar is a parser . </span>
<span style="color:blue">(S (NP (NNP ZPar)) (VP (VBZ is) (NP (DT a) (NN parser))) (. .)) </span>
<span style="color:red">Given a natural language sentence, ZPar produces its syntactic structure .  </span>
<span style="color:blue">(S (VP (VBN Given) (NP (NP (DT a) (JJ natural) (NN language)) (SBAR (S (NP (VBN sentence,) (NNP ZPar)) (VP (VBZ produces) (NP (PRP$ its) (NN syntactic) (NN structure))))))) (. .)) </span>
<span style="color:red">ZPar works by training a model from annotated data , and making analysis using the model .  </span>
<span style="color:blue">(S (NP (NNP ZPar)) (VP (VBZ works) (PP (IN by) (S (VP (VP (VBG training) (NP (DT a) (NN model)) (PP (IN from) (NP (VBN annotated) (NNS data)))) (, ,) (CC and) (VP (VBG making) (NP (NP (NN analysis)) (VP (VBG using) (NP (DT the) (NN model))))))))) (. .)) </span>
<span style="color:red">^D</span>
<span style="color:blue">Parsing has finished successfully. </span>
</code>
</pre>


<h2><a id="Usage-of-ZPar-for-Chinese">Usage of ZPar for Chinese</a></h2>

<p>Suppose that the source files are saved in the folder <code>zpar.zh</code> and the models are saved in <code>models.zh</code>. To run zpar, type <code>zpar/dist/zpar.zh models.zh</code>, and wait for the models to be loaded. After all models are loaded, type in Chinese sentences, and the parses will be printed out on the screen. Alternatively, type <code>zpar/dist/zpar.zh models.zh input output</code> to read Chinese sentences from the <code>input</code> and write the corresponding parses to <code>output</code>.</p>

<p>In the following example, inputs are shown in <span style="color:red">red</span> and outputs are shown in <span style="color:blue">blue</span>.
</p>
<pre>
<code>
bash$ <span style="color:red">zpar/dist/zpar.zh models.zh</span>
<span style="color:blue">Parsing started</span>
<span style="color:blue">Loading scores ... done.</span>
<span style="color:blue">Loading scores... done.</span>
<span style="color:red">这是一个例子。</span>
<span style="color:blue">(IP (NP (PN 这)) (VP (VC 是) (NP (QP (CD 一) (CLP (M 个))) (NP (NN 例子)))) (PU
。))</span>
<span style="color:red">输入一个句子，程序会给出它的句法分析。</span>
<span style="color:blue">(IP (IP (VP (VV 输入) (NP (QP (CD 一) (CLP (M 个))) (NP (NN 句子))))) (PU ，) (NP (NN 程序)) (VP (VV 会) (VP (VV 给出) (NP (DNP (NP (PN 它)) (DEG 的)) (ADJP (JJ 句法)) (NP (NN 分析))))) (PU 。))</span>
<span style="color:red">ZPar通过机器学习获得知识；虽然大多情况正确，但是也会有分析失误。</span>
<span style="color:blue">(IP (IP (NP (NN ZPar)) (VP (PP (P 通过) (NP (NN 机器))) (VP (VV 学习) (IP (VP (VV 获得) (NP (NN 知识))))))) (PU ；) (CP (ADVP (CS 虽然)) (IP (ADVP (AD 大多)) (NP (NN 情况)) (VP (VA 正确)))) (PU ，) (VP (ADVP (AD 但是)) (ADVP (AD 也)) (VP (VV 会) (VP (VE 有) (IP (NP (NN 分析)) (VP (VV 失误)))))) (PU 。))</span>
<span style="color:red">^D</span>
<span style="color:blue">Parsing has finished successfully. </span>
</code>
</pre>

<h2><a id="Usage-of-ZPar-for-English">Usage of ZPar for English</a></h2>

<p>Suppose that the source files are saved in the folder <code>zpar</code> and the models are saved in <code>models.en</code>. To run zpar, type <code>zpar/dist/zpar.en models.en</code>, and wait for the models to be loaded. After all models are loaded, type in English sentences, and the parses will be printed out on the screen. Alternatively, type <code>zpar/dist/zpar.en models.en input output</code> to read English sentences from the <code>input</code> and write the corresponding parses to <code>output</code>.</p>

<p>Run <code>zpar.en</code> without command-line arguments to show options. In particular, the <code>-o</code> option controls the type of output. Use <code>-ot</code> to produce POS-tagged sentences,
and
<code>-od</code> to produce dependency structures.
The default option is
<code>-oc</code> which produces constituent structures (brackets).
</p>

<p>
In the following example, inputs were shown in red and outputs were shown in blue.
</p>
<pre>
<code>
bash$ <span style="color:red">zpar/dist/zpar.en -oc models.en</span>
<span style="color:blue">Parsing started</span>
<span style="color:blue">[tagger] Loading scores ... done.</span>
<span style="color:blue">[parser] Loading scores... done.</span>
<span style="color:red">ZPar is a parser . </span>
<span style="color:blue">(S (NP (NNP ZPar)) (VP (VBZ is) (NP (DT a) (NN parser))) (. .)) </span>
<span style="color:red">Given a natural language sentence, ZPar produces its syntactic structure .  </span>
<span style="color:blue">(S (VP (VBN Given) (NP (NP (DT a) (JJ natural) (NN language)) (SBAR (S (NP (VBN sentence,) (NNP ZPar)) (VP (VBZ produces) (NP (PRP$ its) (NN syntactic) (NN structure))))))) (. .)) </span>
<span style="color:red">ZPar works by training a model from annotated data , and making analysis using the model .  </span>
<span style="color:blue">(S (NP (NNP ZPar)) (VP (VBZ works) (PP (IN by) (S (VP (VP (VBG training) (NP (DT a) (NN model)) (PP (IN from) (NP (VBN annotated) (NNS data)))) (, ,) (CC and) (VP (VBG making) (NP (NP (NN analysis)) (VP (VBG using) (NP (DT the) (NN model))))))))) (. .)) </span>
<span style="color:red">^D</span>
<span style="color:blue">Parsing has finished successfully. </span>
</code>
</pre>

<h2><a id="Usage-of-submodels">Usage of submodels</a></h2>

<p>
ZPar consists of various implementations of a word segmentor, a POS-tagger, a
joint segmentation and tagging system, a dependency parser and a constituency
parser. To compile and use each submodel, run <code>make [submodel]</code>, where
<code>[submodel]</code> can be <code>segmentor</code>, <code>[language].postagger</code>,
<code>[language].depparser</code> or <code>[language].conparser</code>. <code>[language]</code>
can be <code>chinese</code>, <code>english</code> or <code>generic</code>.
For example, if you want to compile the
chinese dependency parser, type <code>make chinese.depparser</code>. To change the
implementation method of
particular submodels, modify the corresponding configurations from Makefile.
For example, the macro <code>SEGMENTOR_IMPL</code> in Makefile defines the implementation of
the segmentor. The corresponding code can be found at
<code>src/chinese/segmentor/SEGMENTOR_IMPL/</code>.
</p>

<h2><a id="note">Notes on versions before 0.7</a></h2>
<a id="note-1">[1]</a> For ZPar versions before 0.7,
the default target <code>zpar</code>
is Chinese and the generic ZPar is <code>zpar.ge</code>.

<h2><a id="Scripts">Scripts</a></h2>

<p>
A <a href='scripts/prettyprint.sh'>pretty print script</a> for the output of the constituent parser. Usage is prettyprint.sh conparser_output. Thanks to Silas S. Brown for providing the script.
</p>

<h2><a id="Reference">Reference</a></h2>

<p>
Yue Zhang and Stephen Clark. 2011. Syntactic Processing Using the Generalized Perceptron and Beam Search. In <em>Computational Linguistics</em>, 37(1), March.
</p>

</div>
</div>
<footer class="text-center">
<p>
ZPar Release 0.7
</p>
</footer>
</body>
</html>
